import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './request'


Vue.use(VueRouter)


let orginPush = VueRouter.prototype.push;
let orginReplace = VueRouter.prototype.replace;

VueRouter.prototype.push = function(location, resolve, reject) {
    if (resolve && reject)
        originPush.call(this, location, resolve, reject)
    else
        orginPush.call(this, location, () => {}, () => {})
}

VueRouter.prototype.replace = function(location, resolve, reject) {
    if (resolve && reject)
        originReplace.call(this, location, resolve, reject)
    else
        orginReplace.call(this, location, () => {}, () => {})
}

let router = new VueRouter({
    routes,
    // 滚动行为
    scrollBehavior(to, from, savedPosition) {
        return { y: 0 }
    }
})

export default router